package data.datafactory;

import java.rmi.RemoteException;

import data.ChooseCourseData.ChooseCourseData;
import data.CourseData.CourseData;
import data.FrameworkData.FrameworkData;
import data.InformData.InformData;
import data.TeachPlanData.TeachPlanData;
import data.UserData.UserData;
import dataservice.chooseCourseDataService.ChooseCourseDatabaseService;
import dataservice.courseDataService.CourseDatabaseService;
import dataservice.datafactoryservice.DatabaseFactory;
import dataservice.frameworkDataService.FrameworkDatabaseService;
import dataservice.informDataService.InformDataService;
import dataservice.teachPlanDataService.TeachPlanDatabaseService;
import dataservice.userDataService.UserDatabaseService;

public class DatabaseFactoryMySqlImpl implements DatabaseFactory{
	private static DatabaseFactoryMySqlImpl databaseFactoryMySqlImpl=null;
	ChooseCourseDatabaseService chooseCourseDatabase;
	CourseDatabaseService courseDatabase;
	FrameworkDatabaseService frameworkDatabase;
	TeachPlanDatabaseService teachPlanDatabase;
	UserDatabaseService userDatabase;
	InformDataService informDatabase;
	
	
	private DatabaseFactoryMySqlImpl(){
		try{
			chooseCourseDatabase=new ChooseCourseData();
			courseDatabase=new CourseData();
			frameworkDatabase=new FrameworkData();
			teachPlanDatabase=new TeachPlanData();
			userDatabase=new UserData();
			informDatabase=new InformData();
		}catch(RemoteException exception){
			exception.printStackTrace();
		}
	}
	
	public static DatabaseFactory getInstance(){
		if (databaseFactoryMySqlImpl==null) {
			databaseFactoryMySqlImpl=new DatabaseFactoryMySqlImpl();
		}
		return databaseFactoryMySqlImpl;
	}

	
	@Override
	public ChooseCourseDatabaseService getChooseCourseDatabaseService() {
		return chooseCourseDatabase;
	}

	@Override
	public CourseDatabaseService getCourseDatabaseService() {
		return courseDatabase;
	}

	@Override
	public FrameworkDatabaseService getFrameworkDatabaseService() {
		return frameworkDatabase;
	}

	@Override
	public TeachPlanDatabaseService getTeachPlanDatabaseService() {
		return teachPlanDatabase;
	}

	@Override
	public UserDatabaseService getUserDatabaseService() {
		return userDatabase;
	}

	@Override
	public InformDataService getInformDataService() {
		return informDatabase;
	}
	

	

}
